/*
 * Copyright (c) 2025 Li Auto Inc. and its affiliates
 * Licensed under the Apache License, Version 2.0(the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
/*
 * {{get_generation_time()}}
 * {{get_project_name()}}
 * {{get_vcos_version()}}
 */

/* Including File */
#include "com.h"

{%- for cbkheaderfile in ComGeneral.ComUserCbkHeaderList %}
#include "{{ cbkheaderfile }}"
{%- endfor %}
#define  COM_START_SEC_CONST
#include "com_memmap.h"
/**********************************************************************************************************************
  Notifications
**********************************************************************************************************************/
// Rx Notification
CONST(com_rx_signal_notification_callout_type, COM_CONST) com_rx_signal_notification[] = {
    {%- for signal in ComConfig.ComRxSignals_totle.keys() %}
        {%- set signalObj = GetSignalObject(signal, ComConfig.ComRxSignals_totle) %}
        {%- if signalObj.ComNotification.Value != "COM_NO_FUNCTION_CALLOUT" and signalObj.ComNotification.Value != None %}
    {{ "/* " ~ ("%+5s" | format(signalObj.ComNotification_id_rx)) ~ " */" }}
            {{- "%-80s" | format(signalObj.ComNotification.Value ~ ",") }}
        {%- endif %}
    {%- endfor %}
    NULL
};

// Rx TimeoutNotification
CONST(com_rx_signal_timeout_notification_callout_type, COM_CONST) com_rx_signal_timeout_notification[] = {
    {%- for signal in ComConfig.ComRxSignals_totle.keys() %}
        {%- set signalObj = GetSignalObject(signal, ComConfig.ComRxSignals_totle) %}
        {%- if signalObj.ComTimeoutNotification.Value != "COM_NO_FUNCTION_CALLOUT" and signalObj.ComTimeoutNotification.Value != None %}
    {{ "/* " ~ ("%+5s" | format(signalObj.ComTimeoutNotification_id_rx)) ~ " */" }}
            {{- "%-80s" | format(signalObj.ComTimeoutNotification.Value ~ ",") }}
        {%- endif %}
    {%- endfor %}
    NULL
};

// Rx InvalidNotification
CONST(com_rx_signal_invalid_notification_callout_type, COM_CONST) com_rx_signal_invalid_notification[] = {
    {%- for signal in ComConfig.ComRxSignals_totle.keys() %}
        {%- set signalObj = GetSignalObject(signal, ComConfig.ComRxSignals_totle) %}
        {%- if signalObj.ComInvalidNotification.Value != "COM_NO_FUNCTION_CALLOUT" and signalObj.ComInvalidNotification.Value != None %}
    {{ "/* " ~ ("%+5s" | format(signalObj.ComInvalidNotification_id_rx)) ~ " */" }}
            {{- "%-80s" | format(signalObj.ComInvalidNotification.Value ~ ",") }}
        {%- endif %}
    {%- endfor %}
    NULL
};

// Rx Error Notification
CONST(com_rx_signal_error_notification_callout_type, COM_CONST) com_rx_signal_error_notification[] = {
    {%- for signal in ComConfig.ComRxSignals_totle.keys() %}
        {%- set signalObj = GetSignalObject(signal, ComConfig.ComRxSignals_totle) %}
        {%- if signalObj.ComErrorNotification.Value != "COM_NO_FUNCTION_CALLOUT" and signalObj.ComErrorNotification.Value != None %}
    {{ "/* " ~ ("%+5s" | format(signalObj.ComErrorNotification_id_rx)) ~ " */" }}
            {{- "%-80s" | format(signalObj.ComErrorNotification.Value ~ ",") }}
        {%- endif %}
    {%- endfor %}
    NULL
};

// Tx Notification
CONST(com_tx_signal_notification_callout_type, COM_CONST) com_tx_signal_notification[] = {
    {%- for signal in ComConfig.ComTxSignals_totle.keys() %}
        {%- set signalObj = GetSignalObject(signal, ComConfig.ComTxSignals_totle) %}
        {%- if signalObj.ComNotification.Value != "COM_NO_FUNCTION_CALLOUT" and signalObj.ComNotification.Value != None %}
    {{ "/* " ~ ("%+5s" | format(signalObj.ComNotification_id_tx)) ~ " */" }}
            {{- "%-80s" | format(signalObj.ComNotification.Value ~ ",") }}
        {%- endif %}
    {%- endfor %}
    NULL
};

// Tx TimeoutNotification
CONST(com_tx_signal_timeout_notification_callout_type, COM_CONST) com_tx_signal_timeout_notification[] = {
    {%- for signal in ComConfig.ComTxSignals_totle.keys() %}
        {%- set signalObj = GetSignalObject(signal, ComConfig.ComTxSignals_totle) %}
        {%- if signalObj.ComTimeoutNotification.Value != "COM_NO_FUNCTION_CALLOUT" and signalObj.ComTimeoutNotification.Value != None %}
    {{ "/* " ~ ("%+5s" | format(signalObj.ComTimeoutNotification_id_tx)) ~ " */" }}
            {{- "%-80s" | format(signalObj.ComTimeoutNotification.Value ~ ",") }}
        {%- endif %}
    {%- endfor %}
    NULL
};

// Tx InvalidNotification
CONST(com_tx_signal_invalid_notification_callout_type, COM_CONST) com_tx_signal_invalid_notification[] = {
    {%- for signal in ComConfig.ComTxSignals_totle.keys() %}
        {%- set signalObj = GetSignalObject(signal, ComConfig.ComTxSignals_totle) %}
        {%- if signalObj.ComInvalidNotification.Value != "COM_NO_FUNCTION_CALLOUT" and signalObj.ComInvalidNotification.Value != None %}
    {{ "/* " ~ ("%+5s" | format(signalObj.ComInvalidNotification_id_tx)) ~ " */" }}
            {{- "%-80s" | format(signalObj.ComInvalidNotification.Value ~ ",") }}
        {%- endif %}
    {%- endfor %}
    NULL
};

// Tx Error Notification
CONST(com_tx_signal_error_notification_callout_type, COM_CONST) com_tx_signal_error_notification[] = {
    {%- for signal in ComConfig.ComTxSignals_totle.keys() %}
        {%- set signalObj = GetSignalObject(signal, ComConfig.ComTxSignals_totle) %}
        {%- if signalObj.ComErrorNotification.Value != "COM_NO_FUNCTION_CALLOUT" and signalObj.ComErrorNotification.Value != None %}
    {{ "/* " ~ ("%+5s" | format(signalObj.ComErrorNotification_id_tx)) ~ " */" }}
            {{- "%-80s" | format(signalObj.ComErrorNotification.Value ~ ",") }}
        {%- endif %}
    {%- endfor %}
    NULL
};

/**********************************************************************************************************************
  Callouts
**********************************************************************************************************************/
// Rx callouts
CONST(com_rx_ipdu_callout_type, COM_CONST) com_rx_ipdu_callouts[] = {
    {%- for IPdu in ComConfig.ComIPdus_totle.keys() %}
    {%- set IPduObj = GetIPduObject(IPdu, ComConfig.ComIPdus_totle) %}
        {%- if IPduObj.ComRxIPduCallout != "COM_NO_FUNCTION_CALLOUT" and IPduObj.ComRxIPduCallout != None %}
    /* {{ IPduObj.MessageName}} */
    {{ IPduObj.ComRxIPduCallout }},
        {%- endif %}
    {%- endfor %}
    NULL
};

// Tx callouts
CONST(com_tx_ipdu_callout_type, COM_CONST) com_tx_ipdu_callouts[] = {
    {%- for IPdu in ComConfig.ComIPdus_totle.keys() %}
        {%- set IPduObj = GetIPduObject(IPdu, ComConfig.ComIPdus_totle) %}
        {%- if IPduObj.ComTxIPduCallout != "COM_NO_FUNCTION_CALLOUT" and IPduObj.ComTxIPduCallout != None %}
    /* {{ IPduObj.MessageName}} */
    {{ IPduObj.ComTxIPduCallout }},
        {%- endif %}
    {%- endfor %}
    NULL
};

// Trigger transmit callouts
CONST(com_tx_ipdu_callout_type, COM_CONST) com_trigger_transmit_ipdu_callouts[] = {
    {%- for IPdu in ComConfig.ComIPdus_totle.keys() %}
        {%- set IPduObj = GetIPduObject(IPdu, ComConfig.ComIPdus_totle) %}
        {%- if IPduObj.ComTriggerTransmitIPduCallout != "COM_NO_FUNCTION_CALLOUT" and IPduObj.ComTriggerTransmitIPduCallout != None %}
    /* {{ IPduObj.MessageName}} */
    {{ IPduObj.ComTriggerTransmitIPduCallout }},
        {%- endif %}
    {%- endfor %}
    NULL
};
#define  COM_STOP_SEC_CONST
#include "com_memmap.h"
